package co.edu.uniandes.moviles.rollerjudge;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.provider.CalendarContract;
import android.provider.CalendarContract.Events;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import co.edu.uniandes.moviles.rollerjudge.logica.Equipo;
import co.edu.uniandes.moviles.rollerjudge.logica.RollerJudge;

public class IniciarPruebaActivity extends Activity{

	protected static final int DATE_DIALOG_ID = 999;
	
	private String genero;
	private String modalidad;
	private String torneo;
	
	private Spinner spinner0, spinner1, spinner2;
	


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		RollerJudge roller = RollerJudge.darInstancia();
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_iniciar_prueba);
		
		spinner0 = (Spinner) findViewById(R.id.spinner0);
		List<String> torneos = new ArrayList<String>();
		for(int i=0;i<roller.darTorneos().size();i++)
		{
			torneos.add(roller.darTorneos().get(i).getNombre());
		}
		ArrayAdapter<String> dataAdapter0 = new ArrayAdapter<String>(this,
			android.R.layout.simple_spinner_item, torneos);
		dataAdapter0.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner0.setAdapter(dataAdapter0);
		
		spinner1 = (Spinner) findViewById(R.id.spinner1);
		List<String> list2 = new ArrayList<String>();
		list2.add("Hombre");
		list2.add("Mujer");
		ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(this,
			android.R.layout.simple_spinner_item, list2);
		dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner1.setAdapter(dataAdapter2);
		
		spinner2 = (Spinner) findViewById(R.id.spinner2);
		List<String> list = new ArrayList<String>();
		
			list.add("Grupo");
			list.add("Individual");
		ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
			android.R.layout.simple_spinner_item, list);
		dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner2.setAdapter(dataAdapter);
		

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}



	@SuppressWarnings("deprecation")
	public void showDialog(String title, String message, final boolean finishAfterClose) {
		AlertDialog alertDialog = new AlertDialog.Builder(this).create();
		alertDialog.setTitle(title);
		alertDialog.setMessage(message);
		alertDialog.setButton("Aceptar", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(final DialogInterface dialog, final int which) {				
				if(finishAfterClose){
					finish();
				}
			}
		});
		alertDialog.show();
	}

	public void iniciarPrueba(View view){
		
		spinner0 = (Spinner) findViewById(R.id.spinner0);
		spinner1 = (Spinner) findViewById(R.id.spinner1);
		spinner2 = (Spinner) findViewById(R.id.spinner2);
		
		torneo= String.valueOf(spinner0.getSelectedItem());
		genero = String.valueOf(spinner1.getSelectedItem());
		modalidad = String.valueOf(spinner2.getSelectedItem());
		
		
			
			System.out.println("torneo:" + torneo +" genero:" + genero +" mod:" + modalidad);
			//RollerJudge.darInstancia().registrarPatinador(nombre, docIdentidad, numero, email, edad, genero, grupo);
			Intent intent = new Intent(this, SeleccionarPruebaActivity.class);
			intent.putExtra("torneo", torneo);
			intent.putExtra("genero", genero);
			intent.putExtra("modalidad", modalidad);

			startActivity(intent);
			
			

			

	}

}


